Skip to content

perf(ripemd160): use hashlib fast path when available#92

Open
m0wer wants to merge 1 commit into
Simplexum:masterfrom
m0wer:pr/ripemd160-hashlib
Open

perf(ripemd160): use hashlib fast path when available#92
m0wer wants to merge 1 commit into
Simplexum:masterfrom
m0wer:pr/ripemd160-hashlib

Conversation

@m0wer
Copy link
Copy Markdown

@m0wer m0wer commented May 26, 2026

The pure-Python RIPEMD160 implementation is hot on every Hash160 and script-evaluation call. When the host OpenSSL build exposes ripemd160 (via the legacy provider on OpenSSL 3, or natively on older builds), delegate to hashlib for a significant speedup.

Probe once at import time with hashlib.new('ripemd160', b'') and keep the pure-Python path as _ripemd160_pure so it remains the source of truth for correctness and continues to work where OpenSSL no longer provides RIPEMD160.

Expand the test module with three cases: vectors via the public ripemd160 entry point, vectors via _ripemd160_pure, and a cross-check that both paths agree on the same input.

The pure-Python RIPEMD160 implementation is hot on every Hash160 and
script-evaluation call. When the host OpenSSL build exposes ripemd160
(via the legacy provider on OpenSSL 3, or natively on older builds),
delegate to hashlib for a significant speedup.

Probe once at import time with hashlib.new('ripemd160', b'') and keep
the pure-Python path as _ripemd160_pure so it remains the source of
truth for correctness and continues to work where OpenSSL no longer
provides RIPEMD160.

Expand the test module with three cases: vectors via the public
ripemd160 entry point, vectors via _ripemd160_pure, and a cross-check
that both paths agree on the same input.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant